﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace JTLeigh.Tools.Development.CopySourceAsHtml.UnitTests
{

    /// <summary>
    /// Unit tests for the <see cref="Safety"/> class.
    /// </summary>
    [TestClass]
    public class SafetyFixture
    {
        #region Methods

        #region AssertArgumentNotNull

        /// <summary>
        /// Ensures <see cref="Safety.AssertArgumentNotNull"/> correctly throws
        /// <see cref="ArgumentNullException"/> when called with a <see langword="null"/>
        /// argument name.
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void TestAssertArgumentNotNullWithNullArgumentName()
        {
            Safety.AssertArgumentNotNull(null, "testValue");
        }

        /// <summary>
        /// Ensures <see cref="Safety.AssertArgumentNotNull"/> correctly throws
        /// <see cref="ArgumentNullException"/> when called with a <see langword="null"/>
        /// argument value.
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void TestAssertArgumentNotNullWithNullArgumentValue()
        {
            Safety.AssertArgumentNotNull("testArgument", null);
        }

        /// <summary>
        /// Ensures <see cref="Safety.AssertArgumentNotNull"/> does not throw an exception when
        /// called with a non-<see langword="null"/> argument value.
        /// </summary>
        [TestMethod]
        public void TestAssertArgumentNotNull()
        {
            Safety.AssertArgumentNotNull("testArgument", "testValue");
        }

        #endregion // AssertArgumentNotNull

        #region AssertIsTrue

        /// <summary>
        /// Ensures <see cref="Safety.AssertIsTrue"/> correctly throws <see cref="ArgumentNullException"/> 
        /// when called with a <see langword="null"/> message.
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void TestAssertIsTrueWithNullMessage()
        {
            Safety.AssertIsTrue(true, null);
        }

        /// <summary>
        /// Ensures <see cref="Safety.AssertIsTrue"/> correctly throws <see cref="InvalidOperationException"/> 
        /// when called with a <see langword="false"/> value.
        /// </summary>
        [TestMethod]
        [ExpectedException(typeof(InvalidOperationException))]
        public void TestAssertIsTrueWithFalseValue()
        {
            Safety.AssertIsTrue(false, "This is a test.");
        }

        /// <summary>
        /// Ensures <see cref="Safety.AssertIsTrue"/> does not throw an exception when called with 
        /// a <see langword="true"/> value.
        /// </summary>
        [TestMethod]
        public void TestAssertIsTrue()
        {
            Safety.AssertIsTrue(true, "This is a test.");
        }

        #endregion // AssertIsTrue

        #endregion // Methods
    }
}
